<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Get result data</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="function.odbc-result-all.html">« odbc_result_all</a></li>
      <li style="float: right;"><a href="function.odbc-rollback.html">odbc_rollback »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="ref.uodbc.html">ODBC 函数</a></li>
    <li>Get result data</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="function.odbc-result" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">odbc_result</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">odbc_result</span> &mdash; <span class="dc-title">Get result data</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.odbc-result-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>odbc_result</strong></span>(<span class="methodparam"><span class="type">resource</span> <code class="parameter">$statement</code></span>, <span class="methodparam"><span class="type"><span class="type">string</span>|<span class="type">int</span></span> <code class="parameter">$field</code></span>): <span class="type"><span class="type">string</span>|<span class="type">bool</span>|<span class="type">null</span></span></div>

  <p class="para rdfs-comment">
   Get result data
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.odbc-result-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt>
<code class="parameter">statement</code></dt>

     <dd>

      <p class="para">
       The ODBC <span class="type">resource</span>.
      </p>
     </dd>

    
    
     <dt>
<code class="parameter">field</code></dt>

     <dd>

      <p class="para">
       The field name being retrieved. It can either be an integer containing
       the column number of the field you want; or it can be a string
       containing the name of the field.
      </p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.odbc-result-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns the string contents of the field, <strong><code>false</code></strong> on error, <strong><code>null</code></strong> for
   NULL data, or <strong><code>true</code></strong> for binary data.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.odbc-result-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   The first call to <span class="function"><strong>odbc_result()</strong></span> returns the
   value of the third field in the current record of the query
   result. The second function call to
   <span class="function"><strong>odbc_result()</strong></span> returns the value of the field
   whose field name is &quot;val&quot; in the current record of the query
   result. An error occurs if a column number parameter for a field
   is less than one or exceeds the number of columns (or fields) in
   the current record. Similarly, an error occurs if a field with a
   name that is not one of the fieldnames of the table(s) that
   is(are) being queried.
  </p>
  <p class="para">
   <div class="example" id="example-1014">
    <p><strong>示例 #1 <span class="function"><strong>odbc_result()</strong></span> examples</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$item_3&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">odbc_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$Query_ID</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">3</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$item_val&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">odbc_result</span><span style="color: #007700">(</span><span style="color: #0000BB">$Query_ID</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"val"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.odbc-result-notes">
  <h3 class="title">注释</h3>
  <p class="para">
   Field indices start from 1. Regarding the way binary or
   long column data is returned refer to
   <span class="function"><a href="function.odbc-binmode.html" class="function">odbc_binmode()</a></span> and
   <span class="function"><a href="function.odbc-longreadlen.html" class="function">odbc_longreadlen()</a></span>.
   
  </p>
 </div>


</div></div></div></body></html>